<!---
Copyright: (c) 2006 The MachBlog Authors
Authors: Matt Woodward (mpwoodward@gmail.com) & Peter J. Farrell (pjf@maestropublishing.com)

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at 

http://www.apache.org/licenses/LICENSE-2.0 

Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and 
limitations under the License.

$Id: UserDAO.cfc 1191 2007-07-14 17:42:46Z pfarrell $

Notes:
--->
<cfcomponent
	displayname="UserDAO"
	output="false"
	hint="UserDAO for MachBlog">
		
	<!---
	PROPERTIES
	--->
	<cfproperty name="datasource" type="org.machblog.datasource.Datasource" required="true" />
	<cfproperty name="resourceBundleFacade" type="org.machblog.facades.ResourceBundleFacade" required="true" />
	
	<!---
	INITIALIZATION / CONFIGURATION
	--->
	<cffunction name="init" access="public" returntype="UserDAO" output="false">
		<cfreturn this />
	</cffunction>

	<cffunction name="setDatasource" access="public" output="false" returntype="void"
		hint="Dependency: injected">
		<cfargument name="datasource" type="org.machblog.datasource.Datasource" required="true" />
		<cfset variables.datasource = arguments.datasource />
	</cffunction>	
	<cffunction name="getDatasource" access="public" output="false" returntype="org.machblog.datasource.Datasource">
		<cfreturn variables.datasource />
	</cffunction>

	<cffunction name="setResourceBundleFacade" access="public" output="false" returntype="void" 
		hint="Dependency: injected">
		<cfargument name="resourceBundleFacade" type="org.machblog.facades.ResourceBundleFacade" required="true" />
		<cfset variables.resourceBundleFacade = arguments.resourceBundleFacade />
	</cffunction>
	<cffunction name="getResourceBundleFacade" access="private" output="false" returntype="org.machblog.facades.ResourceBundleFacade">
		<cfreturn variables.resourceBundleFacade />
	</cffunction>
	
	<!---
	PUBLIC FUNCTIONS
	--->
	<cffunction name="create" access="public" output="false" returntype="void" 
		hint="Creates a new user">
		<cfargument name="user" type="User" required="true" />
	</cffunction>
	
	<cffunction name="read" access="public" output="false" returntype="void"
		hint="Retrieves a user">
		<cfargument name="user" type="User" required="true" />
	</cffunction>
	
	<cffunction name="update" access="public" output="false" returntype="void" 
		hint="Updates a user">
		<cfargument name="user" type="User" required="true" />
	</cffunction>
	
	<cffunction name="delete" access="public" output="false" returntype="void" 
		hint="Deletes a user and that user's entries and comments">
		<cfargument name="user" type="User" required="true" />
	</cffunction>
	
	<cffunction name="emailExists" access="private" output="false" returntype="boolean" 
		hint="Checks to see if an email address already exists">
		<cfargument name="email" type="string" required="true" />
	</cffunction>
	
	<cffunction name="isEmailAddressChange" access="private" output="false" returntype="boolean" 
		hint="Checks to see if the email address associated with an account is being changed on a user update">
		<cfargument name="userId" type="uuid" required="true" />
		<cfargument name="email" type="string" required="true" />
	</cffunction>

</cfcomponent>